import axios from 'axios';
import {API_NEW_VERSION} from '../api';
var qs = require('qs');
const TAXSHEET_TITLES = API_NEW_VERSION + 'taxsheet_titles';
const TAXSHEET_TITLES_BY_MEMBER_USERID = API_NEW_VERSION + 'taxsheet_titles_by_member_userId';
const TAXSHEET_TITLE_BY_ID = API_NEW_VERSION + 'taxsheet_title_by/';
const TAXSHEET_TITLE_MODIFY_IS_DEFAULT = API_NEW_VERSION + 'taxsheet_title_modify_is_default';
const TAXSHEET_TITLES_BY_FREIGHT_CONTRACT = API_NEW_VERSION + 'taxsheet_titles_by_freight_contract';
const TAXSHEET_TITLE_EN_VALUE_ADDED_TAX = API_NEW_VERSION + 'taxsheet_title/en_value_added_tax';

export const searchInvoiceManage = params => {
  return axios.get(TAXSHEET_TITLES, {params: params});
};
export const searchInvoiceManageByFilters = params => {
  return axios.get(TAXSHEET_TITLES_BY_MEMBER_USERID, {params: params});
};
export const saveInvoiceManage = params => {
  return axios.post(TAXSHEET_TITLES, params);
};
export const getInvoiceManage = id => {
  return axios.get(TAXSHEET_TITLE_BY_ID + id);
};
// 根据ID，设置 默认
export const modifyIsDefault = (id, isDefault) => {
  return axios.post(TAXSHEET_TITLE_MODIFY_IS_DEFAULT, qs.stringify({id: id, isDefault: isDefault}));
};
export const searchInvoiceManageByFreightContract = params => {
  return axios.get(TAXSHEET_TITLES_BY_FREIGHT_CONTRACT, {params: params});
};
export const deleteTaxsheetTitle = id => {
  return axios.delete(TAXSHEET_TITLE_BY_ID + '/' + id);
};

export const getTaxsheetTitleEnValueAddedTax = () => {
  return axios.get(TAXSHEET_TITLE_EN_VALUE_ADDED_TAX);
};
